<?php
session_start();

if ($_POST['pwd']!=$_POST['pwd2']) {
	die('<script>alert("密码输入错误");window.location.href="zhuce.php" </script>');
}
if(strtolower($_POST['yzm']) != strtolower($_SESSION['yzm'])){
	die('<script>alert("验证码错误");window.location.href="zhuce.php" </script>');

}

$uname = $_POST['zhanghao'];
$pwd = $_POST['pwd'];
$f=$_POST['ctime']=time();
@mysql_connect('localhost', 'root', 'root');
if (mysql_errno()) {
	die(mysql_errno());
}
mysql_select_db('blog');
mysql_set_charset('utf8');
$sql="insert into `user`(`zhanghao`,`pwd`,`ctime`) values('$uname','$pwd','$f') ";
$res=mysql_query($sql);

if ($res) {
    echo "<script>alert('注册成功');window.location.href='index.php'</script>";
}
else{
    die ("<script>alert('注册失败');window.location.href='zhuce.php'</script>");
}

mysql_close();
